package com.wmcsk.dl.dl;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.wmcsk.dl.dl.internal.DLBroadcastProxyImpl;
import com.wmcsk.dl.dl.internal.DLBroadcastReciverAttachable;
import com.wmcsk.dl.dl.internal.DLPluginManager;
import com.wmcsk.dl.dl.utils.DL;

/**
 * Created by wm on 2016/11/29.
 */
public class DLProxyBroadcastReceiver extends BroadcastReceiver implements DLBroadcastReciverAttachable {
    private static final String TAG = DLProxyService.class.getName();
    private DLBroadcastProxyImpl mImpl = new DLBroadcastProxyImpl(this);
    private DLBroadcastPlugin mRemoteBroadcastReceiver;
    private DLPluginManager mPluginManager;
    public DLProxyBroadcastReceiver(Context context, Intent intent){
        super();
        if(mRemoteBroadcastReceiver==null){
            mImpl.onReceive(context,intent);
        }
    }
    public DLProxyBroadcastReceiver(){
        super();
    }
    @Override
    public void onReceive(Context context, Intent intent) {
        DL.e("DLProxyBroadcastReceiver","广播来了");
        if(mRemoteBroadcastReceiver!=null) {
            mRemoteBroadcastReceiver.onReceive(context, intent);
        }
    }

    @Override
    public void attach(DLBroadcastPlugin remoteBroadcastReciver, DLPluginManager pluginManager) {
        this.mRemoteBroadcastReceiver = remoteBroadcastReciver;
        this.mPluginManager = pluginManager;
    }
}
